/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __IMPL_COMPOSE_RETURN_IMPL_H__
#define __IMPL_COMPOSE_RETURN_IMPL_H__

#include "../tools/head.h"

namespace xos_http_protocol
{

    class compose_return_impl : public xos_stl::mem_item< xos::release_impl< compose_return_impl >, thread_lock >, 
        public i_compose_return
    {
    public:
        typedef xos::release_impl< compose_return_impl > T;

    public:
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //

        static int get_xos_item_data( ITEM_DATA*& item_ptr );
        
    public:
        compose_return_impl();
        ~compose_return_impl();

    public:
        int set_tag_property( xos_box::i_str_property * pProperty );
        int set_send_list( xos_box::i_list * pList );
        int set_body_list( xos_box::i_list * pList );
        int set_cookie_list( xos_box::i_list * pList );
        int reset();
        // 
        // 返回值定义：
        // 
        // 0  : 成功，数据在m_pSendList中
        // -1 : 失败，没有http ret code.
        // 
        int proc();

    protected:
        xos_box::i_str_property * m_pProperty;
        xos_box::i_list * m_pSendList;
        xos_box::i_list * m_pBodyList;
        xos_box::i_list * m_pCookieList;

    protected:
        int add_cookie_tags( char * pBuf, int & nLen, int & nPos );
        int init_data();

    public:
        int init();
        int term();

    };

} // xos_http_protocol

#endif // __IMPL_COMPOSE_RETURN_IMPL_H__
